<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的信息</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/message.css" />
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/checkLogin.js"></script>
    <script src="/js/common.js"></script>
    <script>
        $(function () {
            //查询所有关注的人, 并渲染数据
            $.get(baseUrl + "/users/" + user.id + "/follows", function (data) {
                $(".followUser").renderValues({list:data},{
                    getHref: getHref,
                    setId: function (item, value) {
                        $(item).attr("data-id", value);
                    }
                });

                //点击取消关注, 调用取消关注的接口
                $(".followBtn").click(function () {
                    var starId = $(this).data("id");
                    $.ajax({
                        url: baseUrl + "/users/follow/" + starId,
                        method: 'put',
                        data: {num: -1},
                        success:function (data) {
                            //修改缓存
                            //刷新页面
                            window.location.reload();
                        }
                    });
                });
            })


        });
    </script>
</head>

<body>
<div id="receivers">
    <div class="search-head">
        <div class="row nav-search">
            <div class="col">
                <a href="/mine/profiles.html">
                    <span><i class="fa fa-chevron-left" ></i></span>
                </a>
            </div>
            <div class="col">
                <span>我的关注</span>
            </div>
            <div class="col"></div>
        </div>
    </div>
    <div class="followUser">
        <div render-loop="list">
        <ul class="list-group">
                <li class="list-group-item d-flex justify-content-between align-items-center">
                    <a data-url="/mine/chat.html?id=" render-key="list.id" render-fun="getHref">
                    <div class="item">
                        <img render-src="list.headImgUrl" width="30px"/>
                        <span render-html="list.nickName"></span><br/>
                        <span render-html="list.sign"></span><br/>
                    </div>
                    </a>
                    <button class="btn btn-danger followBtn" data-num="-1"
                        render-key="list.id" render-fun="setId">取消关注</button>
                </li>
        </ul>
        </div>
    </div>
</div>
</body>
</html>